<!--
 * @Author: wangding
 * @Date: 2020-10-30 14:33:25
 * @LastEditTime: 2020-10-30 16:48:59
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \solaxcloud\src\views\system\syslog\index.vue
-->
<template>
    <div>
        <div class="search-box">
            <div class="search-box-sub">
                <span class="lable-text">IP</span>
                <el-input style="width:160px;" v-model="querylist.ip" placeholder="请输入内容"></el-input>
            </div>
            <div class="search-box-sub">
                <span class="lable-text">登录账号</span>
                <el-input style="width:160px;" v-model="querylist.userName" placeholder="请输入内容"></el-input>
            </div>
            <div class="search-box-sub">
                <span class="lable-text">类名</span>
                <el-input style="width:160px;" v-model="querylist.className" placeholder="请输入内容"></el-input>
            </div>
            <div class="search-box-sub">
                <span class="lable-text">方法名</span>
                <el-input style="width:160px;" v-model="querylist.functionName" placeholder="请输入内容"></el-input>
            </div>
            <div class="search-box-sub">
                <span class="lable-text">方法描述</span>
                <el-input style="width:160px;" v-model="querylist.operation" placeholder="请输入内容"></el-input>
            </div>
            <div class="search-box-sub">
                <span class="lable-text">建立时间</span>
                <el-date-picker
                v-model="querylist.startTime"
                type="date"
                placeholder="选择日期"
                format="yyyy-MM-dd"
                value-format='yyyy-MM-dd'
                >
                </el-date-picker>
                -
                <el-date-picker
                v-model="querylist.endTime"
                type="date"
                placeholder="选择日期"
                format="yyyy-MM-dd"
                value-format='yyyy-MM-dd'
                >
                </el-date-picker>
            </div>
        </div>
        <div class="search-box">
            <div class="search-box-sub">
                <el-button type="primary" @click='query'>查询</el-button>
            </div>
        </div>
        <baseTable v-loading="loading"  row-key='sid' :data="dataRows" border  stripe   :column='column' :select='false'>
        </baseTable>
        <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="querylist.current"
        :page-sizes="[10, 20, 30, 50]"
        :page-size="querylist.size"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total">
        </el-pagination>
    </div>
</template>

<script>
import baseTable from '../../../components/common/baseTable'
import moment from 'moment'
export default {
    components: {
        baseTable   
    },
    props: {

    },
    data() {
        return {
            querylist:{
                ip: '',
                userName: '',
                className: '',
                functionName: '',
                operation: '',
                startTime: moment().format("YYYY-MM-DD"),
                endTime: moment().format("YYYY-MM-DD"),
                size: 10,
                current: 1,
            },
            total:1,
            dataRows:[],
            loading:false,
            dataRows:[],
            column:[{
                title: '登录账号',
                value: 'userName',
            },
            {
                title: 'IP',
                value: 'ip',
                slot: 'ip'
            },
            {
                title: '类名',
                value: 'className',
                slot: 'className',
                min_width:'120'
            },{
                title: '方法名',
                value: 'functionName',
                slot: 'functionName'
            },
            {
                title: '方法描述',
                value: 'operation',
                slot: 'operation'
            },{
                title: '操作时间',
                value: 'updateTime',
                slot: 'updateTime'
            },
            {
                title: '参数',
                value: 'params',
                slot: 'params',
                min_width:'300'
            }]
        };
    },
    computed: {

    },
    watch: {

    },
    created() {

    },
    mounted() {
        this.sysLogGetPage()
    },
    methods: {
        async sysLogGetPage(){
            this.loading = true
            if(this.querylist.startTime == null){
                this.querylist.startTime = ''
            }
            if(this.querylist.endTime == null){
                this.querylist.endTime = ''
            }
            let res = await this.API.sysLogGetPage(this.querylist)
            this.total = res.total
            this.dataRows = res.rows ||[]
            this.loading = false
        },
        query(){
            this.querylist.current = 1
            this.sysLogGetPage()
        },
        handleSizeChange(val) {
          this.querylist.size = val
          this.querylist.current = 1
          this.sysLogGetPage()
        },
        handleCurrentChange(val) {
          this.querylist.current = val
          this.sysLogGetPage()
        },
    },
};
</script>

<style  lang="less" scoped>

</style>
